import { RouteRecordRaw } from "vue-router";
import noAuth from "@/views/noAuth.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import AdminLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";
import PersonCenter from "@/components/PersonCenter.vue";
import AdminIndex from "@/components/admin/AdminIndex.vue";
import AdminApiSearch from "@/components/admin/AdminApiSearch.vue";
import AdminUserManage from "@/components/admin/AdminUserManage.vue";
import AdminMessageManage from "@/components/admin/AdminMessageManage.vue";
import AdminTagsManage from "@/components/admin/AdminTagsManage.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },

  {
    path: "/questions",
    name: "浏览题目",
    component: QuestionsView,
  },

  {
    path: "/question_submit",
    name: "最近提交",
    component: QuestionSubmitView,
  },

  {
    path: "/view/question/:id",
    name: "在线做题",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/person",
    name: "个人中心",
    component: PersonCenter,
  },

  {
    path: "/",
    name: "主页",
    component: QuestionsView,
    meta: {
      hideInMenu: true,
    },
  },

  // {
  //   path: "/hide",
  //   name: "隐藏页面",
  //   component: ExampleView,
  //   meta: {
  //     hideInMenu: true,
  //   },
  //   },

  {
    path: "/noAuth",
    name: "无权限",
    component: noAuth,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/admin",
    name: "管理员",
    component: AdminLayout,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
    children: [
      {
        path: "question",
        name: "管理题目",
        component: ManageQuestionView,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
      {
        path: "index", // 相对路径，不需要斜杠
        name: "首页",
        component: AdminIndex,
      },
      {
        path: "updateQuestion",
        name: "更新题目",
        component: AddQuestionView,
        meta: {
          access: ACCESS_ENUM.USER,
        },
      },
      {
        path: "addQuestion",
        name: "创建题目",
        component: AddQuestionView,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
      {
        path: "AdminApiSearch",
        name: "API用量查询",
        component: AdminApiSearch,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
      {
        path: "userManage",
        name: "用户管理",
        component: AdminUserManage,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
      {
        path: "messageManage",
        name: "消息管理",
        component: AdminMessageManage,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
      {
        path: "tagsManage",
        name: "标签管理",
        component: AdminTagsManage,
        meta: {
          access: ACCESS_ENUM.ADMIN,
        },
      },
    ],
  },
];
